package com.cecsmsserve.controller;


import com.cecsmsserve.entity.Activity;
import com.cecsmsserve.service.IActivityService;
import com.cecsmsserve.util.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王郝浠
 * @since 2024-04-17
 */
@CrossOrigin
@RestController
@RequestMapping("/activity")
public class ActivityController {

    @Autowired
    IActivityService service;

    @GetMapping("/findAll")
    public CommonResult findAll(){return service.selectAll();}

    @GetMapping("/selectAllByPage/{current}/{size}")
    public CommonResult selectAllByPage(@PathVariable("current")int current,@PathVariable("size")int size){
        return service.selectAllByPage(current,size);
    }

    @GetMapping("/selectNotBegin")
    public CommonResult selectNotBegin(){
        return service.selectNotBegin();
    }

    @GetMapping("/selectByName/{name}")
    public CommonResult selectByName(@PathVariable("name")String name){
        return service.selectByName(name);
    }

    @GetMapping("/selectByNameByPage/{name}/{current}/{size}")
    public CommonResult selectByNameByPage(@PathVariable("name")String name,@PathVariable("current")int current,@PathVariable("size")int size){
        return service.selectByNameByPage(name,current,size);
    }

    @GetMapping("/selectByState/{state}")
    public CommonResult selectByState(@PathVariable("state") int state){
        return service.selectByState(state);
    }

    @GetMapping("/selectByType/{activityTypeId}")
    public CommonResult selectByType(@PathVariable("activityTypeId")int activityTypeId){
        return service.selectByType(activityTypeId);
    }

    @GetMapping("/selectById/{id}")
    public CommonResult selectById(@PathVariable("id")int id){
        return service.selectById(id);
    }

    @PutMapping("/insert")
    public CommonResult insert(@RequestBody Activity activity){
        return service.insert(activity);
    }

    @PostMapping("/update")
    public CommonResult update(@RequestBody Activity activity){
        return service.update(activity);
    }
}
